package com.wandian.cqcsk.adapter.mine;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wandian.cqcsk.R;
import com.wandian.cqcsk.bean.SignDataBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @date 2019/12/16-13:32
 * @description HomeSignInRecycleAdapter
 **/
public class SignInRecycleAdapter extends BaseQuickAdapter<Integer, BaseViewHolder> {

    private int today;
    private List<SignDataBean> signList = new ArrayList<>();
    public SignInRecycleAdapter(int layoutResId, int nowDay) {
        super(layoutResId);
        this.today = nowDay;
    }

    @Override
    protected void convert(BaseViewHolder helper, Integer item) {
        TextView tv_day_number = helper.getView(R.id.tv_day_number);
        ImageView iv_signed = helper.getView(R.id.iv_signed);
        View view_line = helper.getView(R.id.view_line);
        tv_day_number.setText(item+"");
        tv_day_number.setTextColor(mContext.getResources().getColor(R.color.colornight));
        tv_day_number.setBackgroundResource(R.color.white);
        if(item>28) view_line.setVisibility(View.GONE);
            else view_line.setVisibility(View.VISIBLE);
        if(item<today)tv_day_number.setTextColor(mContext.getResources().getColor(R.color.colornight));
        if(item==today){
            tv_day_number.setBackgroundResource(R.drawable.button_yellow_circle_ball);
            tv_day_number.setTextColor(mContext.getResources().getColor(R.color.white));
        }
        if(item>today)tv_day_number.setTextColor(mContext.getResources().getColor(R.color.colorthree));
        iv_signed.setVisibility(View.GONE);
        if(signList != null && signList.size()>0){
            for(SignDataBean bean :signList){
                int dayNum = -1;
                try {
                    dayNum = Integer.parseInt(bean.getSignTime().substring(8,10));
                    Log.d("dayNum",dayNum+"");
                    if(item == dayNum) iv_signed.setVisibility(View.VISIBLE);
                }catch (Exception e){}
            }
        }
    }

    public void setSignListData(List<SignDataBean> signList){
        this.signList = signList;
        notifyDataSetChanged();
    }

}
